<template>
  <div id="app">
    <el-container>
      <el-header>
      </el-header>
      <el-main>
        <div>
          <p style="margin-left: 100px; font-weight: bold; font-size:30px;text-align: center">欢迎来到星光书城</p>
        </div>
        <el-card style="width: 600px;height: 500px;margin: 0 auto;
                background-color: white;font-weight: bold">
          <el-form label-width="100px" style="width: 400px;margin: 50px auto">
            <el-form-item label="用户名">
              <el-input type="text" placeholder="请输入用户名" v-model="user.username"></el-input>
            </el-form-item>
            <el-form-item label="密码">
              <el-input type="password" placeholder="请输入密码" v-model="user.password"></el-input>
            </el-form-item>
            <el-form-item label="性别">
              <template>
                <el-radio v-model="user.gender" label="1">男</el-radio>
                <el-radio v-model="user.gender" label="2">女</el-radio>
              </template>
            </el-form-item>

            <el-form-item label="电话">
              <el-input type="text" placeholder="请输入你的电话" v-model="user.phone"></el-input>
            </el-form-item>
            <el-form-item label="邮箱">
              <el-input type="text" placeholder="请输入邮箱" v-model="user.email"></el-input>
            </el-form-item>
            <div>
              <el-form-item style="width: 250px;float: left" label="邮箱验证码">
                <el-input type="text" placeholder="请输入邮箱验证码" v-model="user.card"></el-input>
              </el-form-item>
              <el-button style="float: right" type="danger" @click="getCard()">获取验证码</el-button>
            </div>
            <br><br><br>
            <el-form-item align="center">
              <el-button type="primary" @click="reg()" style="margin-right: 100px">注册</el-button>
            </el-form-item>
          </el-form>
        </el-card>
      </el-main>
    </el-container>
  </div>
</template>

<script>
export default {
  name: "reg",
  data() {
    return {
      user: {
        username: "",
        password: "",
        phone: "",
        email: "",
        gender: "",
        card: ""
      }
    }
  },
  methods: {

    reg() {
      axios.post("/user/reg", this.user).then(function (response) {
        alert("注册成功!")
        let responseBody = response.data;

        location.href = '/newLogin.html'
      })
    },
    getCard() {

    }
  }
}
</script>

<style>
body {
  background-image: url("@/assets/imgs/reg_img.png");
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: cover;
}

card__body, .el-main {
  opacity: 0.85;
}
</style>